home *** CD-ROM | disk | FTP | other *** search
- #include "objkit.h"
- #include "help.h"
-
- #include <dos.h>
-
- int ObjectKit::act_ret() // returns RET_OK, RET_CANCEL and RET_MOUSE
- {
- switch(global_i[0])
- {
- case AC_OK: return RET_OK;
- case AC_CANCEL:
- case AC_NULL:
- if(e.what == KEYEVENT)
- return RET_CANCEL;
- return RET_MOUSE;
- default: return 0;
- }
- }
- /////////////////////////////
- void ObjectKit::assign(Visible* toCall, Visible* callFrom,
- int act_type)
- {
- int object_num = Kit::get(toCall);
- callFrom->assign(object_num, act_type);
- }
- /////////////////////////////
- void ObjectKit::exe(int )
- {
- int sub_action = 0; // reserv
- while(1)
- {
- mouseShowCursor();
- int res_cur = current; // reserv
- global_num = current;
- list[current]->exe(sub_action); // event which can not be procecced
- sub_action = 0; // with current object
-
- if(!current) // after pressing on 0th window
- { // - proceed with 1th
- shift();
- continue;
- }
-
- if(global_i[0]) // if exe() sets action_type to global_i[0]
- {
- if(global_i[0] == AC_NEXT) // command for objkit, not for any of its components
- { // usage: menu->find can not find the given string
- moveTo(list[current]->isPoint()); // in the menu->itemList
- sub_action = AC_NEXT;
- continue;
- }
-
- int res = current; // where to return whith ESC-like command
- moveTo(list[current]->isPoint());
- global_num = current;
- list[current]->exe(global_i[0]); // for example: button->exe(), calls menu->exe()
-
- if(global_i[0] == AC_REDRAW || global_i[0] == AC_RESIZE
- || global_i[0] == AC_MOVE)
- {
- return;
- }
-
- if(global_i[0] != AC_NEXT) // return after execution, f.e. button - menu->exe(AC_LEFT) - again return to button
- {
- moveTo(get(list[res]));
- global_num = current;
- if(list[current]->isRet(act_ret()))
- {
- if(global_i[0] != AC_NULL) // if !CANCEL pressed
- global_i[0] = action_type;
- return;
- }
- }
- }
-
- if(!global_i[0])
- {
- if(e.what == KEYEVENT)
- {
- switch(e.key)
- {
- case EVENT_F1:
- if(help_context)
- ::help(help_context);
- break;
- case EVENT_ALT_F3:
- if(!isRet(RET_REMOVE)) // This command is for AppKit
- { // we simply pass it up
- global_i[0] = 0;
- return;
- }
- global_i[0] = AC_ERASE; // We will remove this object
- return; // from the AppKit
- case EVENT_ALT_F4:
- return;
- case EVENT_F2:
- case EVENT_RETURN:
- if(list[current]->isRet(RET_REMOVE | RET_OK
- | RET_MOUSE))
- {
- global_i[0] = action_type;
- return;
- }
- break;
- case EVENT_TAB: mouseHideCursor(); shift();
- mouseShowCursor(); break;
- case EVENT_F6:
- case EVENT_ALT_TAB:
- case EVENT_F10:
- case EVENT_ESC: global_i[0] = 0; return;
- default: break;
- }
- }
- else
- if(e.mouse1()) // mouse pressed
- {
- int n = 1;
- if(!list[0]->mouse_in(e.where())) // outside
- {
- global_i[0] = AC_CLOSE;
- return;
- } // mouse pressed outside
- while(n != used + 1) // where it was pressed?
- {
- if(list[current]->mouse_in(loc(e.where())))
- {
- if(res_cur == current
- && list[current]->isRet(RET_MOUSE))
- {
- global_i[0] = action_type;
- return;
- }
- break;
- }
- mouseHideCursor(); shift(); mouseShowCursor(); n++;
- }
- if(n == used + 1)
- {
- current = 0; // if background object pressed -
- if(help_context) // we check it last, and try
- ::help(help_context); // to show help
- }
- }
- }
- }
- }
- ////////////////////
- void ObjectKit::show()
- {
- mouseHideCursor();
- if(list[0] != 0)
- list[0]->show();
- for(int i = 1; i <= used; i++) // attention !!! 0 - base window
- list[i]->show();
- moveTo(1);
- mouseShowCursor();
- }
- /////////////////////
-